﻿namespace PlusPlusPaint.FileIO
{
    enum Tokens
    {
        Identifier = 0,
        String,
        Integer,
        OpeningParen,
        ClosingParen,
        Colon,
        BeginDocument,
        EndDocument,
        EndOfFile
    }

    class Token
    {
        #region member variables
        Tokens type;
        string value;
        #endregion

        #region properties
        public Tokens Type
        {
            get { return type; }
        }

        public string Value
        {
            get { return value; }
        }
        #endregion

        #region constructors
        public Token(Tokens type, string value)
        {
            this.type = type;
            this.value = value;
        }
        #endregion

        #region overrides
        public override bool Equals(object obj)
        {
 	        if (((object)this) == obj)
                return true;
            Token t = obj as Token;
            if ((object)t == null)
                return false;
            return this.type == t.type && this.value == t.value;
        }

        public bool Equals(Token t)
        {
            return this.type == t.type && this.value == t.value;
        }

        public override int GetHashCode()
        {
            return this.value.GetHashCode();
        }

        #endregion

        #region operator overloads
        public static bool operator == (Token t1, Token t2)
        {
            return t1.Equals(t2);
        }

        public static bool operator != (Token t1, Token t2)
        {
            return !(t1 == t2);
        }
        #endregion
    }
}
